package com.oocl.ita.linstner.chatframe;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import com.oocl.ita.qqclientt.QQClient;
import com.oocl.ita.sakura.client.Client;
import com.oocl.ita.sakura.ioutil.NetIOUtil;
import com.oocl.ita.sakura.protocol.Protocol;

public class ShakeListener implements ActionListener {

	@Override
	public void actionPerformed(ActionEvent e) {
		/*
		 * 点击shake按钮，发给toClient发送报文
		 */
		System.out.println("ShakeListener : " + QQClient.getClient());
		
		// 封装shake报文
		Protocol protocol = new Protocol("shake");
		System.out.println("ShakeListener : " + QQClient.getClient() + " the dest Client is " + QQClient.getToClient());
		protocol.encapsulate("to", new Client(QQClient.getToClient().getAccout()));
		System.out.println("fuck : " + protocol);
		System.out.println("ShakeListener : shake" + QQClient.getClient() + " send shake protocol " + protocol);
		
		// 发送
		try {
			QQClient.getOos().writeObject(protocol);
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}

}
